import component from "../../../common/component";
import {Button, Col, Input,Row,Tag} from "antd";

class borrecords extends component {
    //搜索栏  搜索栏不可指定搜索属性搜索
    getSearchRow(): null {
        return <Input.Group>
            <Row gutter={8}>
                <Col span={6}>
                    <Input onChange={this.handleChange} allowClear placeholder="设备名称" onPressEnter={this.reload}
                           name={'name'}/>
                </Col>
                <Col span={3}>
                    <Button type={'primary'} onClick={this.reload}>搜索</Button>
                </Col>
            </Row>
        </Input.Group>;
    }
    //主体部分页眉
    getColumns(): null {
        return [
            {
                title: '设备编号',
                dataIndex: 'equCode',
                key: 'equCode',
                width: 150,          
            },
            {
                title: '设备名称',
                dataIndex: 'equName',
                key: 'equName',
                width: 150,         
            },
            //借用人姓名
            {
                title: '借用人姓名',
                dataIndex: 'userName',
                key: 'userName',
                width: 150,         
            },
            //借用人学号
            {
                title: '借用人学号',
                dataIndex: 'userNumber',
                key: 'userNumber',
                width: 150,         
            },
            {
                title: '预计归还时间',
                dataIndex: 'etime',
                key: 'etime',
                width: 200,   
            },
            {
                title: '借用理由',
                dataIndex: 'text',
                key: 'text',
                width: 150,   
            },
            {
                title: '借用状态',
                dataIndex: 'state',
                key: 'state',
                width: 150,  
                render (state) { 
                    let config = {                      
                        '0': <Tag color="default">审核中</Tag>,
                        '1': <Tag color='success'>已通过</Tag>,
                        '2': <Tag color="processing">已归还</Tag>,
                        '3': <Tag color="error">已拒绝</Tag>
                    }
                    return config[state];
                }
            },
            {
                title: '管理员答复',
                dataIndex: 'answer',
                key: 'answer',
                width: 150,   
            },
            {
                title: '答复时间',
                dataIndex: 'atime',
                key: 'atime',
                width: 200,   
            },
            {
                title: '申请时间',
                dataIndex: 'applyTime',
                key: 'applyTime',
                width: 150,   
                sorter: (a, b) => {
                    // 将日期转成毫秒
                      const t1 = new Date(a.applyTime).getTime();
                      const t2 = new Date(b.applyTime).getTime();
                      return t1- t2
                    },
                    sortDirections: ['descend', 'ascend'],
                    defaultSortOrder: 'descend'
                
            },
        ];
    }
}

export default borrecords;
